Ext.onReady(function(){
Ext.Ajax.request({
	url:'/usercontrol/index_display_list/',
	method : 'post',
	success:function(response){
		var results =  Ext.decode(response.responseText);
		if(results.success){

		    var IndexStore = Ext.create('Ext.data.Store', {
		    	data:results.available,
		    	fields: ['id','text']
		    });    
		    var IndexDisplayForm = Ext.widget('form', {
		        bodyPadding: 10,
		        items:[{
		            xtype: 'itemselector',
		            name: 'indexform',
		            id: 'indexform-field',
		            anchor: '100%',
		            margin:'10',
		            store: IndexStore,
		            displayField: 'text',
		            valueField: 'id',
		            allowBlank: false,
		            blankText:'请选择',
		            value: results.selected
		        },{
		            xtype: 'container',
		            style: 'text-align:center',
		            items: [{
		                xtype: 'button',
		                margin:'20',
		                text: '重&nbsp;&nbsp;&nbsp;置',
		                handler: function(){
		                    Ext.getCmp('indexform-field').clearValue();
		                }
		            },{
		                xtype: 'button',
		                margin:'20',
		                text: '保&nbsp;&nbsp;&nbsp;存',
		                handler: function(){
		                    var form = Ext.getCmp('indexform-field').up('form').getForm();
		                    if (form.isValid()){
								form.submit({
									submitEmptyText:false,
									waitTitle : '请稍候',
									waitMsg : '正在处理......',
									url : '/usercontrol/index_display_save/',
									success : function(form, action) {
										Ext.Msg.alert('系统提示', action.result.message);
									},
									failure : function(form, action) {
										Ext.Msg.alert('系统提示', action.result.message);
									}
								});
		                    }
		                }
		            }]
		        }]
		    });
		    
			Ext.create('Ext.container.Viewport',{
				layout:'fit',
				renderTo: 'indexdisplay-grid',
				items:[IndexDisplayForm]
			});

		}else{
        	Ext.Msg.alert('系统提示', results.message);
        }
	}
});	
	
});